import pymysql

db = pymysql.connect(host='localhost', user='root', password='123456',port=3306, database='test')
cursor = db.cursor()
sql = """
INSERT INTO
  EMPLOYEE (FIRST_NAME, LAST_NAME, AGE, SEX, INCOME)
VALUES
  ('Mac','Su','20','M',5000)
"""

try:
    cursor.execute(sql)
    db.commit()
except:
    db.rollback()


db.close()